package com.zc.custom.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.custom.mapper.ChargeCustomUserMapper;
import com.zc.custom.domain.ChargeCustomUser;
import com.zc.custom.service.IChargeCustomUserService;

import static com.ruoyi.common.utils.SecurityUtils.getDeptId;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 客户Service业务层处理
 *
 * @author glb
 * @date 2023-05-19
 */
@Service
public class ChargeCustomUserServiceImpl implements IChargeCustomUserService
{
    @Autowired
    private ChargeCustomUserMapper chargeCustomUserMapper;

    /**
     * 查询客户
     *
     * @param customId 客户主键
     * @return 客户
     */
    @Override
    @DataScope(deptAlias = "d")
    public ChargeCustomUser selectChargeCustomUserByCustomId(Long customId)
    {
        return chargeCustomUserMapper.selectChargeCustomUserByCustomId(customId);
    }

    /**
     * 查询客户列表
     *
     * @param chargeCustomUser 客户
     * @return 客户
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<ChargeCustomUser> selectChargeCustomUserList(ChargeCustomUser chargeCustomUser)
    {
        return chargeCustomUserMapper.selectChargeCustomUserList(chargeCustomUser);
    }

    /**
     * 新增客户
     *
     * @param chargeCustomUser 客户
     * @return 结果
     */
    @Override
    public int insertChargeCustomUser(ChargeCustomUser chargeCustomUser)
    {
        chargeCustomUser.setDeptId(getDeptId());
        chargeCustomUser.setCreateBy(getUsername());
        chargeCustomUser.setCreateTime(DateUtils.getNowDate());
        return chargeCustomUserMapper.insertChargeCustomUser(chargeCustomUser);
    }

    /**
     * 修改客户
     *
     * @param chargeCustomUser 客户
     * @return 结果
     */
    @Override
    public int updateChargeCustomUser(ChargeCustomUser chargeCustomUser)
    {
        chargeCustomUser.setUpdateBy(getUsername());
        chargeCustomUser.setUpdateTime(DateUtils.getNowDate());
        return chargeCustomUserMapper.updateChargeCustomUserHT(chargeCustomUser);
    }

    /**
     * 批量删除客户
     *
     * @param customIds 需要删除的客户主键
     * @return 结果
     */
    @Override
    public int deleteChargeCustomUserByCustomIds(Long[] customIds)
    {
        return chargeCustomUserMapper.deleteChargeCustomUserByCustomIds(customIds);
    }

    /**
     * 删除客户信息
     *
     * @param customId 客户主键
     * @return 结果
     */
    @Override
    public int deleteChargeCustomUserByCustomId(Long customId)
    {
        return chargeCustomUserMapper.deleteChargeCustomUserByCustomId(customId);
    }
}
